package com.xy.config;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Title:
 * Description:
 * Created by yujuan on 2017/9/25.
 */
@Component
public class TestScheduling {
    private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");

//    @Scheduled(fixedDelay = 5000)
    //第一次延迟2秒后执行，之后按fixedRate的规则每5秒执行一次
    //@Scheduled(cron="*/5 * * * * *")
    @Scheduled(initialDelay = 2000,fixedDelay = 5000)
    public void doSomething(){
        System.out.println("现在的时间是:"+dateFormat.format(new Date()));
    }
}
